package main

import (
	"fmt"
	"log"

	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
)

const (
	host     = "localhost"
	port     = 5432
	user     = "admin"
	password = "admin"
	dbname   = "test"
)

type Name struct {
	Id   int
	Name string //字段首字母大写
	Age  int
}

func main() {
	//http://gorm.io/docs/index.html
	//https://www.kancloud.cn/kancloud/xorm-manual-zh-cn/
	psqlInfo := fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbname)
	db, err := gorm.Open("postgres", psqlInfo)
	defer db.Close()

	if err != nil {
		log.Panicln(err)
	} else {
		log.Println("fasf")
	}

	//	t1 := Name{name: "fweqfe", age: 19}
	db.LogMode(true)
	db.Create(&Name{Name: "fweqfe", Age: 19})

}
